package com.smbms.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.smbms.entity.Permissions;
import com.smbms.entity.SmbmsRole;
import com.smbms.mapper.SmbmsRoleMapper;
import com.smbms.service.RoleService;

@Transactional
@Service
public class RoleServiceImpl implements RoleService {

	
	@Autowired
	SmbmsRoleMapper roleMapper;
	
	public List<SmbmsRole> selectAll() {
		return roleMapper.selectAll();
	}

	@Override
	public List<Permissions> selectPermissionsByRoleId(Long id) {
		return roleMapper.selectPermissionsByRoleId(0l,id);
	}

	@Override
	public int addRolePermission(Long roleId, Long[] permIds) {
		roleMapper.deletePermissByRoleId(roleId);
		return roleMapper.addRolePermiss(roleId, permIds);
	}

	@Override
	public List<Permissions> selectRolePermissions(Long id) {
		return roleMapper.selectRolePermissions(id);
	}

}
